package com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.glsc.ngateway.common.base.domain.mysql.gateway.FlowFormBaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.time.LocalDate;

/**
 * @author xuchang
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Entity
@Where(clause = "deleted = 0")
@SQLDelete(sql = "update t_gw_flow_form_equipment_server_apply set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@SQLDeleteAll(sql = "update t_gw_flow_form_equipment_server_apply set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@Table(name = "t_gw_flow_form_equipment_server_apply")
@org.hibernate.annotations.Table(appliesTo = "t_gw_flow_form_equipment_server_apply", comment = "物理设备申领及上架流程form表单-主表")
public class FlowFormEquipmentServerApply extends FlowFormBaseEntity {

    private static final long serialVersionUID = -9064911687763509442L;

    @Column(name = "flow_desired_date", columnDefinition = "date comment '希望使用日期'")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonSerialize(using = LocalDateSerializer.class)
    @JsonDeserialize(using = LocalDateDeserializer.class)
    private LocalDate flowDesiredDate;

    @Column(name = "others", columnDefinition = "Text comment '其他'")
    private String others;

    @Column(name = "appendices_file_id_list", columnDefinition = "Text comment '附件'")
    private String appendicesFileIdList;

}
